package com.zb.Service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zb.Service.UserService;
import com.zb.entity.User;
import com.zb.mapper.UserMapper;

@Component("UserService")
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper userMapper;

	public int count() {
		return userMapper.count();
	}

	public int deleteUser(int userid) {
		return userMapper.deleteUser(userid);
	}

	public List<User> findUserList(int index, int size, String username,
			String realname) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("index", (index-1)*size);
		map.put("size", size);
		map.put("username", username);
		map.put("realname", realname);
		return userMapper.findUserList(map);
	}

	public User getUserById(int userid) {
		
		return userMapper.getUserById(userid);
	}

	public int saveUser(User user) {
		return userMapper.saveUser(user);
	}

	public int updateUser(User user) {
		return userMapper.updateUser(user);
	}

	// 登录
	public User getLogin(String name, String pwd) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("name", name);
		params.put("pwd", pwd);
		return userMapper.getLogin(params);
	}

	// 修改密码
	public void updateUserPwd(User user) {
		userMapper.updateUserPwd(user);

	}

	public List<User> getLeaderAll() {

		return userMapper.getLeaderAll();
	}

	public List<User> getUserByDeptId(int did) {
		return userMapper.getUserByDeptId(did);
	}

	public List<User> findUserListByDR(int deptid,int roleid) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("deptid", deptid);
		map.put("roleid", roleid);
		return userMapper.findUserListByDR(map);
	}

	public int getSheduleState(int uid) {
		return userMapper.getSheduleState(uid);
	}

	public int updateSheduleState(int shedule,int uid) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("shedule", shedule);
		map.put("uid", uid);
		return userMapper.updateSheduleState(map);
	}

}
